package com.e3.web.core.server;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.e3.core.base.SessionContext;
import com.e3.web.core.client.GxtClientSession;
import com.e3.web.core.client.ResourceRPCService;
import com.e3.web.core.client.WebException;

public class ResourceRPCServiceImpl extends GwtRPCAction implements	ResourceRPCService {

	public GxtClientSession getClientSession(boolean isDebug) throws WebException {
		SessionContext.setDeveloping(isDebug);
		
		GxtClientSession clientSession = new GxtClientSession();
		
		clientSession.setUserId(SessionContext.getUserID());
		clientSession.setUserCode(SessionContext.getUserCode());
		clientSession.setUserName(SessionContext.getUserName());
		
		clientSession.setCorpId(SessionContext.getCorpID());
		clientSession.setCorpCode(SessionContext.getCorpCode());
		clientSession.setCorpName(SessionContext.getCorpName());
		
		clientSession.setSuperAdmin(SessionContext.isSuperAdimin());
		clientSession.setLocalCorp(SessionContext.isLocalCorp());
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		Date date = SessionContext.getSession().getLoginTime();
		if(date == null){
			date = new Date();
		}
		String time = sdf.format(date);
		clientSession.setLoginTime(time);
		
		return clientSession;
	}

}
